#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
string s;
int mp[26];
int kind;
int main()
{
    cin >> s;
    s = " " + s;
    int n = s.size();
    int left = 1;
    int right = 1;
    int ret = n;
    while (right < n)
    {
        if (mp[s[right] - 'a']++ == 0)
        {
            kind++;
        }
        while (kind == 26)
        {
            ret = min(ret, right - left + 1);
            if (mp[s[left] - 'a']-- == 1)
            {
                kind--;
            }
            left++;
        }
        right++;
    }
    cout << ret;
    return 0;
}